﻿using System;
using System.Text;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using Skyworth.CRM.Common;
using Skyworth.CRM.Service.IBLL;
using Skyworth.CRM.Service.Entity;

namespace Skyworth.CRM.Web.SalesManagement
{
    public partial class SelectPricePolicy : BasePage
    {
        private static IPricePolicyBLL policyBLL = IocContainer.Instance.Resolve<IPricePolicyBLL>();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
               
            }
            BindData();
        }

        private void BindData()
        {
            try
            {
                Hashtable parameter = new Hashtable();
                StringBuilder strWhere = new StringBuilder(" where 1=1 ");

                if (!string.IsNullOrEmpty(this.txtPolicyCode.Text))
                {
                    strWhere.Append(" and PolicyCode like '%" + this.txtPolicyCode.Text + "%'");
                }
                if (!string.IsNullOrEmpty(this.txtPolicyName.Text))
                {
                    strWhere.Append(" and PolicyName like '%" + this.txtPolicyName.Text + "%'");
                }


                this.DataGrid1.Visible = true;
                DataTable dt = policyBLL.Query(strWhere.ToString(), parameter);
                if (dt != null && dt.Rows.Count > 0)
                {
                    this.DataGrid1.DataSource = dt;
                    this.DataGrid1.DataBind();
                }
                else
                {
                    this.DataGrid1.Visible = false;
                }

            }
            catch (Exception exception)
            {
                Logger.Instance.Error(exception);
            }
        }




      




        protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
        {
            DataGrid1.CurrentPageIndex = e.NewPageIndex;
            BindData();

        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindData();
        }

    }
}
